package com.ikas.ai.server.module.steady.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author wuyf
 * @date 2023/12/15 11:40
 */
@Getter
@AllArgsConstructor
public enum AlarmConditionEnum {
    /**
     * 预警条件 (阈值监测) 1：大于，2：大于等于，3：小于，4：小于等于；(趋势监测) 5：上升，6：下降
     */
    GT(1, "大于", 0, "取时间范围内最小值进行判断"),
    GE(2, "大于等于", 0, "取时间范围内最小值进行判断"),
    LT(3, "小于", 1, "取时间范围内最大值进行判断"),
    LE(4, "小于等于", 1, "取时间范围内最大值进行判断"),
    UP(5, "上升", 0, "取时间范围内最小值进行判断"),
    DW(6, "下降", 1, "取时间范围内最大值进行判断"),
    ;

    private Integer value;
    private String desc;
    private Integer groupVal;
    private String groupDesc;

    public static AlarmConditionEnum getEnumByValue(Integer value) {
        for (AlarmConditionEnum alarmConditionEnum : AlarmConditionEnum.values()) {
            if (Objects.equals(value, alarmConditionEnum.getValue())) {
                return alarmConditionEnum;
            }
        }
        return null;
    }

    public static AlarmConditionEnum getEnumByDesc(String desc) {
        for (AlarmConditionEnum alarmConditionEnum : AlarmConditionEnum.values()) {
            if (desc.equals(alarmConditionEnum.getDesc())) {
                return alarmConditionEnum;
            }
        }
        return null;
    }
}
